package com.example.administrator.xiaoxiang.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.example.administrator.xiaoxiang.R;
import com.example.administrator.xiaoxiang.activity.IndentActivity;
import com.example.administrator.xiaoxiang.activity.SafetyActivity;
import com.example.administrator.xiaoxiang.activity.SettingActivity;
import com.example.administrator.xiaoxiang.activity.VoucherActivity;

import static com.example.administrator.xiaoxiang.R.id.btn_ic1;
import static com.example.administrator.xiaoxiang.R.id.btn_ic2;
import static com.example.administrator.xiaoxiang.R.id.btn_ic3;
import static com.example.administrator.xiaoxiang.R.id.btn_ic4;
import static com.example.administrator.xiaoxiang.R.id.btn_ic5;

/**
 * A simple {@link Fragment} subclass.
 */
public class PersonalFragment extends Fragment implements View.OnClickListener {

;
    public static final String TAG = "PersonalFragment";
    private RelativeLayout ic1, ic2, ic3, ic4, ic5, ic6, ic7, ic8, ic9, ic10, ic11;

    public PersonalFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View rootView = inflater.inflate(R.layout.fragment_personal, container, false);
        ic1 = (RelativeLayout) rootView.findViewById(R.id.btn_ic1);
        ic2 = (RelativeLayout) rootView.findViewById(R.id.btn_ic2);
        ic3 = (RelativeLayout) rootView.findViewById(R.id.btn_ic3);
        ic4 = (RelativeLayout) rootView.findViewById(R.id.btn_ic4);
        ic5 = (RelativeLayout) rootView.findViewById(R.id.btn_ic5);
        ic6 = (RelativeLayout) rootView.findViewById(R.id.ic6);
        ic7 = (RelativeLayout) rootView.findViewById(R.id.ic7);
        ic8 = (RelativeLayout) rootView.findViewById(R.id.ic8);
        ic9 = (RelativeLayout) rootView.findViewById(R.id.ic9);
        ic10 = (RelativeLayout) rootView.findViewById(R.id.ic10);
        ic11 = (RelativeLayout) rootView.findViewById(R.id.ic11);
        ic1.setOnClickListener(this);
        ic2.setOnClickListener(this);
        ic3.setOnClickListener(this);
        ic4.setOnClickListener(this);
        ic5.setOnClickListener(this);
        ic6.setOnClickListener(this);
        ic7.setOnClickListener(this);
        ic8.setOnClickListener(this);
        ic9.setOnClickListener(this);
        ic10.setOnClickListener(this);
        ic11.setOnClickListener(this);
        return rootView;
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {

            case btn_ic1://我的订单
                indentStart("ic1");
                break;
            case btn_ic2://代  付款
                indentStart("ic2");
                break;
            case btn_ic3://待收货
                indentStart("ic3");
                break;
            case btn_ic4://现金券
                voucherStart("ic4");

                break;
            case btn_ic5://免息卷
                voucherStart("ic5");
                break;
            case R.id.ic6://我的账单
                Toast.makeText(getContext(), "你点击了我的账单", Toast.LENGTH_SHORT).show();
                break;
            case R.id.ic7://额度提升
                startActivity(new Intent(getContext(), SafetyActivity.class));
                break;
            case R.id.ic8://账户管理
               settingStart("ic8");
                break;
            case R.id.ic9://联系客服
                settingStart("ic9");
                break;
            case R.id.ic10://常见问题
                settingStart("ic10");
                break;
            case R.id.ic11://设置
                settingStart("ic11");
                break;
        }

    }
//跳转到待收货  代付款  定订单页面的方法
    public void indentStart(String id) {
        Intent intent = new Intent(getContext(), IndentActivity.class);
        intent.putExtra("id",id);
        startActivity(intent);
    }

    //跳转到带进群页面的
    public  void voucherStart(String id){
       Intent intent = new Intent(getContext(), VoucherActivity.class);
        intent.putExtra("id",id);
        startActivity(intent);
    }
      public void settingStart(String id){
          Intent intent = new Intent(getContext(), SettingActivity.class);
          intent.putExtra("id",id);
          startActivity(intent);
    }

}
